import networkx as nx
import numpy as np
import os
import json
import pickle
import matplotlib.pyplot as plt

from config import data_path
from config import graphs_path

from utils_network import load_all_graphs
from utils_network import read_data

from utils_downstream import draw_event
from utils_downstream import close_top_k
from utils_downstream import history_response
from utils_downstream import group_evolution



if __name__ == "__main__":
    event_list, topic_dict, member_list, group_list = read_data(data_path,rebuild=False)
    all_graphs = load_all_graphs(graphs_path)
    
    # test utils_downstream.py
    close_k = close_top_k(all_graphs=all_graphs, member_list=member_list, event_id="100007432", member_id="9289550", k=5)
    is_draw = draw_event(graph=all_graphs[0], save_path="./test.png", with_labels=False)
    history_res = history_response(all_graphs=all_graphs, group_list=group_list, event_id="100007432", member_id="9289550")
    group_evo = group_evolution(all_graphs=all_graphs, group_id="462914")
    
    print("=======================================")
    print("close_k of 9289550 in 100007432:", close_k)
    print("=======================================")
    print("history response of 9289550 before 100007432:", history_res)
    print("=======================================")
    print("462914 evolution:", group_evo)
    print("=======================================")

    


